package com.richapp.launcher.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.richapp.launcher.R;

public class ChildRoomCurtainsListAdapter extends BaseAdapter {
	LayoutInflater layoutInflater = null;
    String testData[] = null;
	//现在使用测试数据，后期需要在构造函数上加上ArrayList
	public ChildRoomCurtainsListAdapter(Context context) {
		layoutInflater = LayoutInflater.from(context);
		testData = context.getResources().getStringArray(R.array.roomcurtains);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return testData.length;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder viewHolder = null;
		if (convertView == null) {
			viewHolder = new ViewHolder();
			convertView = layoutInflater.inflate(R.layout.child_listroomcurtains_item,
					null);
			viewHolder.roomCurtainsName = (TextView) convertView
					.findViewById(R.id.roomcurtains_name);
			viewHolder.roomCurtains = (ImageView) convertView
					.findViewById(R.id.room_curtains);
			convertView.setTag(viewHolder);
		} else {
            viewHolder = (ViewHolder) convertView.getTag();  
		} 
		viewHolder.roomCurtainsName.setText(testData[position]);
		return convertView;
	}

	final class ViewHolder {
		private TextView roomCurtainsName = null;
		private ImageView roomCurtains = null;
	}
}
